#ifndef MEASURE_ARITHMETIC_H
#define MEASURE_ARITHMETIC_H

#ifdef __cplusplus
extern "C" {
#endif

#include "vdsdef.h"
#include "measure.h"
#include "measure_p.h"

#ifdef DEF_MEASURE_ARITHMETIC_H
#define EXT_MEASURE_ARITHMETIC
#else
#define EXT_MEASURE_ARITHMETIC extern
#endif 

#define ADCSCALE 65536

#define EdgeFail    (-1) //为负数代表无上升沿或者下降沿，无法计算顶端值和底端值
#define PvalueFail  100000
#define NvalueFail  (-100000)
#define AMP_DATA_WINDOW  (7*256)
#define AMP_DATA_WINDOW_OF_PULSE_WIDTH   (5*256)
#define ADC_PRECISON_LIMIT (0xFFE0)

    typedef enum {
        RISE = 0,
        FALL
    } edge_enum;

    EXT_MEASURE_ARITHMETIC void measureItemCalc(MeasureParam *measParam);
    EXT_MEASURE_ARITHMETIC void measureItemCalcOne(MeasureItem *measItem);
    EXT_MEASURE_ARITHMETIC void measureItemVrms(MeasureItem *measItem);
    EXT_MEASURE_ARITHMETIC void measureItemPauseVrms(MeasureItem *measItem);
    EXT_MEASURE_ARITHMETIC void measureItemVtopVbaseShoot(MeasureItem *measItem);
    EXT_MEASURE_ARITHMETIC S32 findFristEdgePosition(MeasureItem *measItem, S32 winHigh, S32 winLow, S32 *edgeType);
    EXT_MEASURE_ARITHMETIC void findRisePosition(MeasureItem *measItem, S32 start, S32 winHigh, S32 winLow);
    EXT_MEASURE_ARITHMETIC void findFallPosition(MeasureItem *measItem, S32 start, S32 winHigh, S32 winLow);
    EXT_MEASURE_ARITHMETIC void getVtopVbaseShoot(MeasureItem *measItem, S32 edgeType);
    EXT_MEASURE_ARITHMETIC void getCycleRMS(MeasureItem *measItem, S32 edgeType);
    EXT_MEASURE_ARITHMETIC void measureItemRiseFallTime(MeasureItem *measItem);
    EXT_MEASURE_ARITHMETIC void getFirstRiseEdge(MeasureItem *measItem, S32 start, S32 winHigh, S32 winLow);
    EXT_MEASURE_ARITHMETIC void getFirstFallEdge(MeasureItem *measItem, S32 start, S32 winHigh, S32 winLow);
    EXT_MEASURE_ARITHMETIC void getEdgeNum(MeasureItem *measItem, S32 start, S32 winHigh, S32 winLow);
    EXT_MEASURE_ARITHMETIC void measureItemPulseWidth(MeasureItem *measItem);
    EXT_MEASURE_ARITHMETIC void getFirstNWidth(MeasureItem *measItem, S32 start, S32 winHalf, S32 winHigh, S32 winLow);
    EXT_MEASURE_ARITHMETIC void getFirstPWidth(MeasureItem *measItem, S32 start, S32 winHalf, S32 winHigh, S32 winLow);
    EXT_MEASURE_ARITHMETIC void measureItemFreqCycle(MeasureItem *measItem);


    EXT_MEASURE_ARITHMETIC void measureDelayCalc(MeasureParam *measParam);
    EXT_MEASURE_ARITHMETIC void getDelayTime(MeasureParam *measParam, S32 cha, S32 chb);
    EXT_MEASURE_ARITHMETIC void getDelayTimeEdgePostion(MeasureItem *measItem);
    EXT_MEASURE_ARITHMETIC void getDelayRRFF_time(MeasureParam *measParam, S32 cha, S32 chb);


    EXT_MEASURE_ARITHMETIC void measureResult(MeasureParam *measParam, MeasureResult *result);


    EXT_MEASURE_ARITHMETIC F32 getVoltageValuesPerData(S32 voltScale);


#ifdef __cplusplus
}
#endif

#endif /* MEASURE_ARITHMETIC_H */

